import json
from flask import Flask, request, jsonify,Blueprint
from server.sqlauthserver import user_login, user_register
from . import doctor_user_api
# doctor_user_api = Blueprint('doctor_user_api', __name__)

@doctor_user_api.route('/login', methods=['POST'])
def login():
    data = request.json
    print(data)
    result = user_login(data)
    # print(result["role"])
    if result["err"] == 0:
        if result["role"] != "doctor":
            return {"err": 4, "message": "请使用医务人员账号登录", "data": {}}
    return result
@doctor_user_api.route('/info', methods=['GET'])
def get_userinfo():
    userid = request.args.get('userid')
    print(userid)
    result ={"code": 20000, "err": 0, "message": "success",
                  "data": {"userid": 1, "roles": "[admin]",
                           "introduction": 'I am a super administrator', "avatar": 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', "name": "cz"}}

    return result




